package com.spider.test01;

public class Demo2 {
    public static void main(String[] args) {
        System.out.println("请输入数字：");
        int n = new java.util.Scanner(System.in).nextInt();
        System.out.println(n+"的阶乘是："+factorial(n));
    }
    //需求:计算n的阶乘
    public  static int  factorial(int n){
        int sum = 1;
        for (int i = 1; i <= n; i++) {
            sum *= i;
        }
        return sum;
    }

}
